Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

285
Visualizações
SpringBoot MongoDB returns "Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable"

I tried adding a new collection to my API/DB today, and when I try to POST or GET, I get this 500 error response:

{
  "cause": null,
  "message": "Id must be assignable to Serializable! Object of class [null] must be an instance of interface java.io.Serializable"
}

However the POST is actually successful, I can see the new data in the DB.

Model:

@Setter
@Getter
public class League {

    private String name;
    private String shortName;
    private List<Team> teams;
}

Repository:

@RepositoryRestResource(collectionResourceRel = "leagues", path = "leagues", excerptProjection = LeagueProjection.class)
public interface LeagueRepository extends MongoRepository<League, String> {

}

Projection:

@Projection(name="LeagueProjection", types={League.class})
public interface LeagueProjection {

    String getName();
    String getShortName();
}

I am not doing anything special. I have multiple other collections that work fine.

I am using spring-boot 1.5.1.

Thanks!

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Adding the field:

@Id private String id;

to my model seems to have resolved the issue.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda